import formChange from "./formChange"
import typeOf from "./typeOf"
import empty from "./empty"

/**
 * 俩个值是否相等
 * @param v1
 * @param v2
 */
const equal = (v1 , v2) => {
  switch (typeOf(v1)) {
    case 'undefined' :
    case 'boolean'  :
    case 'number'  :
    case 'string' :
    case 'null'   : return v1 === v2;
    case 'object' : return typeOf(v2 , 'object') && empty(formChange(v1 , v2));
    case 'array'  : return typeOf(v2 , 'array') && v1.length === v2.length && empty(formChange(v1 , v2));
    default : return false;
  }
}

export default equal;